package com.phoenix.jsef.framework.accessfilter;

/**
 * 是否为 DBNull Or StringEmpty的过滤条件构造器
 *
 * @author 李启联
 */
class AccessFilterIsDBNullOrStringEmptyItem extends AccessFilterItem {

    /**
     * 是否为 DBNull Or StringEmpty过滤条件构造器
     *
     * @param andCondition 使用 and 或者 or 条件拼接
     * @param filterKey    属性名称
     * @param filterValue  (true 为 is null or 空值  ;false 为 is not null or 不為空值 )
     */
    AccessFilterIsDBNullOrStringEmptyItem(boolean andCondition, String filterKey, Object filterValue) {
        super(andCondition, filterKey, filterValue);
    }

    @Override
    public String toString() {
        String returnStr;
        if ((Boolean) filterValue) {
            returnStr = ((andCondition) ? " AND " : " OR ") + "( " + filterKey + " IS NULL OR " + filterKey + " = '' )";
        } else {
            returnStr = ((andCondition) ? " AND " : " OR ") + "( " + filterKey + "  IS NOT NULL OR " + filterKey + " <> '' )";
        }
        return returnStr;
    }
}